package com.sjk.pojo;

import com.sjk.utils.EncryptAlgorithm;

import java.io.Serializable;

/**
 * @author lohhhha
 * 2023/5/20
 */

public class UserRegisterInfo implements Serializable {
    private String username;
    private String password;
    private String gender;
    private int age;
    private String name;
    private String birthdate;
    private String phonenum;
    private String id;
    private String address;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getBirthdate() {
        return birthdate;
    }

    public void setBirthdate(String birthdate) {
        this.birthdate = birthdate;
    }

    public String getPhonenum() {
        return phonenum;
    }

    public void setPhonenum(String phonenum) {
        this.phonenum = phonenum;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public User getUser(int authority) {
        User ret = new User();
        ret.setUsername(this.username);
        // encrypt password
        ret.setPassword(EncryptAlgorithm.encrypt(this.password));
        ret.setAddress(this.address);
        ret.setAge(this.age);
        ret.setId(this.id);
        ret.setBirthdate(this.birthdate);
        ret.setGender(this.gender);
        ret.setAuthority(authority);
        ret.setName(this.name);
        ret.setId_encrypt(EncryptAlgorithm.encrypt(this.id));
        ret.setId6_encrypt(EncryptAlgorithm.encrypt(this.id.substring(this.id.length() - 6)));
        ret.setPhonenum(this.phonenum);
        ret.setPhonenum_encrypt(EncryptAlgorithm.encrypt(this.phonenum));
        ret.setPhonenum4_encrypt(EncryptAlgorithm.encrypt(this.phonenum.substring(this.phonenum.length() - 4)));
        return ret;
    }
}
